<!DOCTYPE html>
<html>
  <title>具名插槽</title>
  <head>
    <meta charset="utf-8" />
  </head>
  <body>
    <template id="t-cpn">
      <div>
        <slot name="left"><span>left</span></slot>
        <slot name="center"><span>center</span></slot>
        <slot name="right"><span>right</span></slot>
      </div>
    </template>

    <div id="div1">
      <!-- 注意slot属性是放在要替换的元素标签内，不是放在外层自定义标签<cpn>内部 -->
      <cpn><button slot="left">替换左边</button></cpn>
      <cpn><h2 slot="center">替换中间</h2></cpn>
      <cpn><p slot="right">替换右边</p></cpn>
    </div>
    <script src="../../js/vue.js"></script>
    <script>
      const app = new Vue({
        el: "#div1",
        components: {
          cpn: {
            template: "#t-cpn"
          }
        }
      });
    </script>
  </body>
</html>
